让我们创建另一个循环,以测试正确颜色但不正确位置的猜测。
- 在函数内部使用另一个 Loop with Range 。将计数器更改为 peg_num ,范围更改为 4。
- 检查 if guess[peg_num] 在 code 中而不在 colors_tried 和 colors_matched 中。
- 如果符合,则添加一个名为 marker 的 "black" Circle ,带有 x 和 y 坐标,直径为 15。
- 如果符合,将 guess[peg_num] Append 到 colors_matched 列表。
To navigate the page using the TAB key, first press ESC to exit the code editor.